//---------------------------------------------------------------------------- // File: C3DRenderBank.h // Version: 2.0 // Class: C3DRenderBank // Type: 3D Bank Manager // Author: Ken Anderson // Date: 8/16/04 // Updates: // 9/13/04 -- The DeallocateSlot member function was fixed as it previously had // been attempting to pass the renderbank callback as the a cbank callback; // however, these are two different structures causing memory leaks & access // violation errors. // // Version 2.0 -- System updated to manage the HRBE callback only due to the complexities of // the individual handles provided by the special buffer & object. // // OS dependant: NA // Desc: Contains a specialized bank that uses the CBank structure as a private // member variable, to manage and control the bank of void data structures. // The class was designed to act as a protection manager, not allowing // the bank to be destroyed without cleaning up the specialized void // handles that were used. // // Notes: NOT DERVIVED FROM CBANK // Error codes can be reviewed in CBank.h // // Required headers: // 1) Common.h -- Contains common structures, definitions, type definitions // and other features not dependant on any operating // system or system. // //---------------------------------------------------------------------------- //Prevent redefinition #ifndef __C3DRenderBank__ #define __C3DRenderBank__ #include "Common.h" #define BKERR_SLOTREMOVALHALTED (BK_COUNT + 0) //The slot removal process was halted. ///////////////////////////// // DEFINITIONS // ///////////////////////////// typedef enum RENDER_BANK_STATES { BSV_NEW, //Object is new and requires a specialized rendering buffer. BSV_UPDATE, //Object requres a new render buffer and the old one to be destroyed. BSV_RENDER, //Object is safe for rendering. BSV_REFRESH, //Safe to render, but requires updating. BSV_DESTROY, //Object needs to be destroyed. } C3DRenderBankStates; ///////////////////////////// // TYPE DEFS // ///////////////////////////// typedef struct RENDER_BANK_ELEMENT { C3DRenderBankStates rbsState; //Render bank states. void* pSpecialBuffer; //Special buffer used by renderer. void* p3DObject; //Object that called the bank and requested a slot. void* pNext; //Allows for a secondary RBE link. } RBE, *PRBE, **HRBE; class C3DRenderBank { //Class member variables private: CBank* m_pbank; //Class member functions public: //Constructors & Destructors C3DRenderBank(); ~C3DRenderBank(); BANKERR Create(); void Destroy(); //Common 3d object management. //The following members should be called by the common 3d object management. //Object updating features for common 3d objects to manage. BANKERR AllocateSlot(HRBE* tCallback); //Allocate a slot in the bank. BANKERR DeallocateSlot(HRBE* tCallback); //Tell the bank to clean up current slot. BANKERR RetrieveCallback(BST bstIndex, HRBE* tCallback); //Returns the callback based on the index. BST Depth(); //Returns the size of the bank. BANKERR UpdateBuffer(HRBE hCallback); //Inform the bank to update the current slot & rebuild buffer. BANKERR RefreshSlot(HRBE hCallback); //Inform the bank to refresh or update the current slot. private: void Cleanup(); //Clean up the render bank. }; #endif